<!--------------------------------------------------------------
>//	Company:	    HTHK
>//	NAME:	    Employee.jsp
>//	TITLE:	    Employee Information 
>//	FUNCTION:	    result is one record
>//	BY:	         Beyes Xia
>//	DATE:	    2004-1-14 10:35
>// --------------------------------------------------------------
-->
<!--------------------------------------------------------------
  Amend record
  Date          Version         Author          Description
  06/07/2004    1.0             Beyes           For log 1304.
---------------------------------------------------------------->
<%@ include file="../tssheader.jsp" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%
	String[] employee = new String[11]; 
	employee = (String[])request.getAttribute("employee");
	
	String isOneRecord = request.getParameter("isOneRecord");
%>
<!------ Add by Beyes Xia for log 1304 7/6/2004 11:01 AM -------------------------->
<script Language="Javascript" src="<%=contextPath%>/tss/employee/Calendar1-821.js"></script>
<script language="JavaScript1.1">
function mySubmit()
{
	if(checkDate(fm.last_date) && checkFromTO())
	{
		fm.submit();
	}
}
function last_date_select()
{
   var today = new Date();
   show_calendar('fm.last_date', today.getMonth(), today.getYear(), 'YYYY/MM/DD');
}
function checkFromTO()
{
	if(fm.join_date.value.length!=0 && fm.last_date.value.length!=0 && fm.join_date.value>fm.last_date.value)
	{
		alert("Last Date must be latter than Join Date");
		return false;
	}
	return true;
}
function checkDate(object) 
{
    var obj=object;
    var d = obj.value;
    if(d.length !=0 && d.length !=10)
    {
    		alert("Please input correct date with format as YYYY/MM/DD.");
    		return false;
    }	
    if(d.length==10)
    {
	    if (d.substring(4,5)!="/" || d.substring(7,8)!="/") 
	    {
		  alert("Please input correct date with format as YYYY/MM/DD.");
		  return false;
	    }
	    var day = d.substring(8,10);
	    var month = d.substring(5,7);
	    var year = d.substring(0,4);
	    if (day==null || isNaN(day)) 
	    {
			alert("Please input correct date with format as YYYY/MM/DD.");
			return false;
	    }
	    if (month==null || isNaN(month)) {
			alert("Please input correct date with format as YYYY/MM/DD.");
			return false;
	    }
	    if (day==null || isNaN(day)) {
			alert("Please input correct date with format as YYYY/MM/DD.");
			return false;
	    }
	    if (day < 1 || day > 31)
	    {
			alert("Please input correct date with format as YYYY/MM/DD.");
			return false;
	    }
	    if (month < 1 || month > 12) {
			alert("Please input correct date with format as YYYY/MM/DD.");
			return false;
	    }
	    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			alert("Please input correct date with format as YYYY/MM/DD.");
			return false;
	    }
	    if (month == 2) 
	    {
	        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	    		if (day > 29 || (day==29 && !isleap))
	    		 {
				alert("Please input correct date with format as YYYY/MM/DD.");
				return false;
	        	 }
	    } 
	}
    return true;
 }
</script> 
<!--------------- End add by Beyes Xia -------------------------------->

<h2>Employee Information</h2>

<!--------------- Add by Beyes Xia for log 1304 7/6/2004 11:02 AM----------------------->
<form id=fm method=post action='<%=contextPath%>/servlet/tss.employee.EmployeeUpdate' >
<!--------------- End add by Beyes Xia ------------------------------------>
<table>
<tr>
<td>Staff No.:</td>
<td><input type=text name='staff_no' value='<%=employee[0]%>' class=read readonly ></td>
</tr>
<tr>
<td>English Name:</td>
<td><input type=text name='english_name' value='<%=(employee[3]==null?"":employee[3])+" "+employee[1]%>' class=read readonly ></td>
</tr>
<tr>
<td>Chinese Name</td>
<td><input type=text name='' value='<%=employee[1]+" "+employee[2]%>' class=read readonly ></td>
</tr>
<tr>
<td>Join Date</td>
<td><input type=text name='join_date' value='<%=employee[4]%>' class=read readonly ></td>
</tr>
<!--------------- Modify by Beyes Xia for log 1304 7/6/2004 10:22 AM------------------->
<tr>
<td>Last Date</td>
<td>
	<input type=text name='last_date' maxlength=10  align='left' value='<%=employee[5]==null?"":employee[5]%>' >
	<input type=button name=but_cal onClick="last_date_select()" value='...'>(YYYY/MM/DD)
</td>
</tr>
<!--------------- End modify by Beyes Xia -------------------------------->
<tr>
<td>Department</td>
<td><input type=text name='' value='<%=employee[6]%>' class=read readonly ></td>
</tr>
<tr>
<td>Cost Center</td>
<td><input type=text name='' value='<%=employee[7]%>' class=read readonly ></td>
</tr>
<tr>
<td>Position</td>
<td><input type=text name='' value='<%=employee[8]%>' class=read readonly ></td>
</tr>
<tr>
<td>Employee Type</td>
<td><input type=text name='' value='<%=employee[9]%>' class=read readonly ></td>
</tr>
</table>
<br>
<hr>
<p>
<!------ Modify by Beyes Xia for log 1304 7/6/2004 11:03 AM---------------------------->
	<INPUT type=button value='Save' onclick='mySubmit()'>
<%	
	if(isOneRecord.equals("Y"))
	{
%>	
	<INPUT type=button value=Back onclick="location.href='<%=contextPath%>/tss/employee/EmployeeSearch.jsp'">
<%
	}
	if(isOneRecord.equals("N"))
	{
%>
	<INPUT type=button value=Back onclick="location.href='javascript:history.back()'">
<%
	}
%>
<!------ End modify by Beyes Xia --------------------------------------------->
</p>
</form>
<%@ include file="../tssfooter.jsp" %>
</body>
</html>
